﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema version="0.7.2" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:qu="urn:queryunit" targetNamespace="urn:queryunit">
	<xs:element name="QueryUnit" type="qu:QueryUnit">
	</xs:element>

	<xs:complexType name="QueryUnit">
		<xs:sequence minOccurs="1" maxOccurs="unbounded">
			<xs:element name="TestSets" type="qu:TestSets">				
			</xs:element>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="TestSets">
		<xs:sequence>
			<xs:element name="TestSet" minOccurs="1" maxOccurs="unbounded" type="qu:TestSet"></xs:element>
		</xs:sequence>		
	</xs:complexType>

	<xs:complexType name="TestSet">
		<xs:sequence>
			<xs:element type="qu:Configuration" name="Configuration" minOccurs="1" maxOccurs="1" />
			<xs:element type="qu:TestFixture" name="TestFixture" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" />
		<xs:attribute name="type" type="qu:TestType" />
	</xs:complexType>

	<xs:complexType name="Configuration">
		<xs:sequence>
			<xs:element name="DatabaseConnection" type="xs:string" minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="TestFixture">
		<xs:sequence>
			<xs:element name="Test" type="qu:Test" minOccurs="1" maxOccurs="unbounded"/>
		</xs:sequence>
	</xs:complexType>

	<xs:complexType name="Test">
		<xs:sequence>
			<xs:element name="Query" type="xs:string" minOccurs="1" maxOccurs="1"/>
			<xs:element name="ExpectedResults" type="qu:ExpectedResults" minOccurs="1" maxOccurs="1"/>
		</xs:sequence>
		<xs:attribute name="name" type="xs:string" />
	</xs:complexType>

	<xs:complexType name="ExpectedResults">
		<xs:choice>
			<xs:sequence>
				<xs:element name="CellSetResult" type="qu:ExpectedResult" minOccurs="1" maxOccurs="unbounded"/>
			</xs:sequence>
			<xs:sequence>
				<xs:element name="ResultSet" type="qu:ExpectedResult" minOccurs="1" maxOccurs="unbounded"/>
			</xs:sequence>
		</xs:choice>
	</xs:complexType>

	<xs:complexType name="ExpectedResult">
		<xs:attribute name="value" type="xs:string"/>
    <xs:attribute name="format" type="xs:string" use="optional"/>
		<xs:attribute name="ordinal" type="xs:integer"/>
		<xs:attribute name="type" type="qu:ResultType"/>
		<xs:attribute name="assertion" type="qu:AssertionType"/>
	</xs:complexType>

	<xs:simpleType name="TestType">
		<xs:list>
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="MDX" />
					<xs:enumeration value="TSQL" />
				</xs:restriction>
			</xs:simpleType>
		</xs:list>
	</xs:simpleType>

	<xs:simpleType name="ResultType">
		<xs:list>
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="Decimal" />
					<xs:enumeration value="String" />
				</xs:restriction>
			</xs:simpleType>
		</xs:list>
	</xs:simpleType>

	<xs:simpleType name="AssertionType">
		<xs:list>
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="AreEqual" />
          <xs:enumeration value="AreNotEqual" />
          <xs:enumeration value="Greater" />
          <xs:enumeration value="Less" />
				</xs:restriction>
			</xs:simpleType>
		</xs:list>
	</xs:simpleType>
</xs:schema>